﻿@model SYJ.Model.Entities.SysUser
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <title></title>
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.11.3.min.js"></script>
    <script src="~/Content/layui/layui.js"></script>
    <script src="~/Scripts/Common.js"></script>

</head>
<body class="layui-container" >
    <div class="layui-row">


        <form class="layui-form" action="" method="post">
            <input type="hidden" id="id" name="id" value="@Model.id" />
            <div class="layui-form-item">
                <label class="layui-form-label">用户账号</label>
                <div class="layui-input-block">
                    <input type="text" name="user_name" id="user_name" required lay-verify="required" placeholder="请输入用户账号" autocomplete="off" value="@Model.user_name" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户邮箱</label>
                <div class="layui-input-block">
                    <input type="text" name="email" required lay-verify="email" placeholder="请输入用户邮箱" autocomplete="off" value="@Model.email" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户密码</label>
                <div class="layui-input-block">
                    <input type="text" name="password" required lay-verify="required" placeholder="请输入用户密码" autocomplete="off" value="@Model.password" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-block">
                    <input type="text" name="nickname" required lay-verify="required" placeholder="请输入昵称" autocomplete="off" value="@Model.nickname" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">作者名字</label>
                <div class="layui-input-block">
                    <input type="text" name="author" required lay-verify="required" placeholder="请输入作者名字" autocomplete="off" value="@Model.author" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">常用地址</label>
                <div class="layui-input-block">
                    <input type="text" name="address" placeholder="请输入常用地址" autocomplete="off" value="@Model.address" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">QQ号码</label>
                <div class="layui-input-block">
                    <input type="text" name="qq" placeholder="请输入QQ号码" autocomplete="off" value="@Model.qq" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    @{
                    if (Model.sex == "男")
                    {
                        <input type="radio" name="sex" value="男" title="男" checked="checked">
                        <input type="radio" name="sex" value="女" title="女">
                    }
                    else
                    {
                        <input type="radio" name="sex" value="男" title="男">
                        <input type="radio" name="sex" value="女" title="女" checked="checked">
                    }
                    }

                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">电话</label>
                <div class="layui-input-block">
                    <input type="text" name="telphone" lay-verify="phone" placeholder="请输入电话" autocomplete="off" value="@Model.telphone" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">账号状态</label>
                <div class="layui-input-block">
                    <select name="status" id="status">
                        <option value="1">停用</option>
                        <option value="0">正常</option>

                    </select>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">用户签名</label>
                <div class="layui-input-block">
                    <textarea name="signature" placeholder="请输入用户签名" class="layui-textarea"> @Model.signature </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="form1" type="button">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
         <script>

             layui.use(['form', 'jquery'], function () {
                 var form = layui.form;
                 var $ = layui.jquery;
                 var status = '@Model.status';
                 debugger;
                 if (status == null || status == "") {
                     status = 0;
                 }
                 $("#status").val(status);
                 if ('@Model.id' != "0") {
                     $("#user_name").attr("disabled", true);
                 }

                 form.render('select'); //刷新select选择框渲染


                 //监听提交
                 form.on('submit(form1)', function (data) {
                     $.ajax({
                         type: "POST",
                         url: '/admin/SysUserMgr/AddOrUp',
                         data: data.field,
                         dataType: "json",
                         //traditional: true, //传数组进后台需要设置该属性
                         success: function (data) {
                             if (data) {
                                 layer.msg("操作成功,2秒后自动关闭", function () {
                                     parent.layui.table.reload('tid');
                                     //当你在iframe页面关闭自身时
                                     var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                     parent.layer.close(index); //再执行关闭
                                 });
                             }
                             else {
                                 layer.msg("操作失败");
                             }
                         }
                     });
                     return false;
                 });

             });
    </script>
</body>



</html>